Hello everybody and welcome back to our first lesson about the none pay packets.
Soon the last lessons we have seen that Python has limitations when it comes to large scale numerical
operations python is simply too slow for this and therefore name the that package was created.
And the roots go back to the year 1995 where it was developed under the name The MARICH And later in
the year 2006 it was finally released as an unpaid package.
Since then umpires.
The first choice in Python when it comes to a numerical computations and fast vector US operations overlaps
arrays.
And we will see in the next lessons what exactly mean with this.
However to give you an intuition typically so in many tasks that we use the NUM pay packets there is
no further need for for loops or if and Elif and Ed statements.
So with NUM PI we can reduce many lines of code and all of that can also increase the performance of
our code and also umpires typically the number one choice for mathematical functions in general and
in particular for linear algebra and also for a random number generation.
All right.
So let's stop coding and before we can use non PI we have to impart an umpire with the keyboard import
num pi and then we say please use num pi.
As with the previous Asian MP so that's by convention.
So most of the users use the convention or the appreciation.
MP fine umpire and then we create a list.
So we already know lists a list from one to 10 including here at us and then we can transform the list
into an so-called umpire Ray umpire race also India race fast and flexible container of large numerical
data sets and these arrays enable us to perform operations on whole blocks of data and in a victorious
fashion.
So we will see later what I exactly mean with this.
But first of all let's transform the listen to an umpire ravers the function p dot array.
So now you can see that look similar to our lists here actually.
And here with the array red you can see that here it's an umpire Ray.
Earlier we learned that typically and to put a notebook and there's no need to use and the print function.
So we can print the array by just executing the cell and it gives the same information then with the
print function.
However the way how the output is represented are formatted sometimes different and here.
This is the case.
So if we explicitly use the print function
then we can see that the output is formatted in a different way and here the array looks like a vector.
And yeah this is exactly how an num high array behaves later with operations.
So like a mathematical back to also if you multiply a vector with a scalar let's say to then element
twice each element will be multiplied by two.
And that was exactly the behaviour that we didn't see the lists with lists.
If we multiply a list by to be just get two times the copy of the list concatenated but we will go more
into detail later in the next session.
So now let's first check the data type of my array and it's num pie in the array.
So umpire Ray or India right.
I mean the same with it and same as lists the umpire Ray is a contain of elements so we can also iterate
over an umpire Ray.
So for element in my array I can print all elements 1 2 10 and 12.
We have learned that lists can store many different elements so and for many different data types so
our lists can star and enter into to float string and a boolean object so if we iterate over the elements
of this list and print out the type of each element so we can see that erm began an integer and float
and string and boolean object.
So once an integer 2.5 is a float object dog is a string object and true is a boolean object.
So now we are coming to the first and they are one of the most important differences between an umpire
and the list.
So let's try to transform the list here into an umpire Ray called a and then let's try to iterate over
the elements and print out the type of each element and we can see each element as a string so we can
see here also one is transformed into a string 2.5 is now a string and also true as the string and a
string is typically the least common denominator.
So yeah we can transform an into John a float into a string.
You can also transform a boolean object into a string but you cannot transform a string into any of
the other data types.
So the thing is typically the lowest common denominator.
Yeah and yeah.
That's a general rule it out in an umpire Ray.
You can only store one data type and typically and that's why if an umpire famous and successful listen
that they are you typically use it with numerically the data sort with integers and floats.
And that's one of the reasons why an umpire race are much faster when it comes to numerical operations
because none by a dozen tests to check which data types it contains that knows.
OK I only have integers off loads and I do not have to care about what data types I have.
And yeah that makes it more powerful and more faster and then the numerical operations.
All right.
To give you a better intuition let's create an umpire Ray B with three integers so the type of still
an umpire Ray and this the attribute detail.
We can check the single data type that B contains.
So here it's an integer.
And now when we transform one element here into and float object by just adding a dot so he can see
that num pi transforms all elements into a float object and let's check it here.
The data type of the umpire AP is a float.
Now if you transform two here into a string
you can see that all elements are transformed into a string all right.
So this is it for the time being and yeah we learned actually that an impact array contains only one
data type and that's now one of the major differences to a list.
And then the next lesson we learn about bacteria's operations.
This is another main difference to a list.
So we hope to see in the next lesson by.